package com.dmall.algorithm.chapter01;

import java.util.Arrays;

public class Leetcode189V2 {

    public void rotate(int[] nums, int k) {
        int[] arr = new int[nums.length];
        System.arraycopy(nums, 0, arr, 0, arr.length);
        System.out.println(Arrays.toString(arr));
        for (int i = 0; i < nums.length; i++) {
            nums[(i + k) % arr.length] = arr[i];
        }
    }

    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 4, 5, 6, 7};
        Leetcode189V2 leetcode189 = new Leetcode189V2();
        leetcode189.rotate(nums, 3);
        System.out.println(Arrays.toString(nums));
    }
}
